#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define OJ_TEST 0
#define LOCAL_TEST 0

#define M 901

static int max(int a, int b){ return a>b?a:b; }
static int min(int a, int b) { return a<b?a:b; }

static void solve(void){
	int minute, hour;
	double ang;
	while(scanf("%d:%d", &hour, &minute)!=EOF){
		if(hour==0 && minute==0) break;
		hour = hour%12;
		ang = fabs(minute*6 - (hour*30+minute*0.5));
		if(ang>=180) ang = 360 - ang;
		printf("%.3f\n", ang);
	}
}
#if OJ_TEST
	int main(int ac, char *av[]){
		solve();
		return 0;
	}
#elif  LOCAL_TEST
	void run(void){
		solve();
	}

#else

#endif
